<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆页面</title>

<script type="text/javascript">
	function _change() {
		var img = document.getElementById("img");
		img.src = "/OrderSystem/VerifyCodeServlet?a=" + new Date().getTime();
	}
</script>

</head>
<body>

<%
	/* 错误信息非空判断 */
	String message = "";
	String msg = (String)request.getAttribute("msg");
	if (msg != null) {
		message = msg;
	}
%>

<%
	/* 从cookie中获取用户信息 */
	Cookie[] cookies = request.getCookies();
	String uname = "";
	if (cookies != null) {
		for (Cookie c : cookies) {
			if ("uname".equals(c.getName())) {
				uname = c.getValue();
			}
		}
	}
%>

	<h1>登陆页面</h1>
	<form action="/OrderSystem/LoginServlet" method="post">
		用户名：<input type="text" name="username" value=<%=uname %>><br>
		密 码：<input type="password" name="password"><br>
		验证码：<input type="text" size="4">
		<img src="/OrderSystem/VerifyCodeServlet" id="img">
		<a href="javascript:_change()">换一张</a><br>
		<input type="submit" value="登陆"><br>
		<font color="red"><b><%=message %></b></font>
	</form>

</body>
</html>